<template>
  <div>
    <div class="houtai_container">
      <div id="box"></div>
      <div id="box2"></div>
    </div>
  </div>
</template>
<script>
export default {
  mounted() {
    this.drawBar();
    this.drawLine();
  },
  methods: {
    drawBar() {
      // 基于准备好的dom，初始化echarts实例
      let myChartBar = this.$echarts.init(document.getElementById("box"));
      // 绘制图表
      myChartBar.setOption({
        title: { text: "在Vue中使用echarts柱状图" },
        tooltip: {},
        xAxis: {
          data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
        },
        yAxis: {},
        series: [
          {
            name: "销量",
            type: "bar",
            data: [5, 20, 36, 10, 10, 20],
          },
        ],
      });
    },
    drawLine() {
      // 基于准备好的dom，初始化echarts实例
      let myChartLine = this.$echarts.init(document.getElementById("box2"));
      // 绘制图表
      myChartLine.setOption({
          title: { text: "在Vue中使用echarts折线图" },
        xAxis: {
          type: "category",
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [820, 932, 901, 934, 1290, 1330, 1320],
            type: "line",
          },
        ],
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.houtai_container {
  width: 100%;
  height: 100%;
  display: inline-flex;
  justify-content: space-around;
  align-items: center;
}
#box {
  width: 30%;
  height: 300px;
}
#box2{
    width: 30%;
    height: 300px;
}
</style>